#include "BallTypeFactory.h"
#include "SketcherHelper.h"

#define RADIO 14

BallTypeFactory::BallTypeFactory() {
}

BallTypeFactory::~BallTypeFactory(){
}

Element * BallTypeFactory::createElement( XMLElement * element) {
	return this->createBallType(element);
}

ballType * BallTypeFactory::createBallType(XMLElement* ballTyp) {
	
	Color * lineColor;
	Color * color;
	Texture* texture;
	
	lineColor = FactoryUtil::getInstance()->buildColor(ballTyp,"colorLinea");
	color = FactoryUtil::getInstance()->buildColor(ballTyp,"colorElemento");
	texture = FactoryUtil::getInstance()->buildTexture(ballTyp);
	ballType* bt=  new ballType(color,lineColor,texture);
	bt->setRadious(RADIO);
	if(texture != NULL) {
		bt->setSurface(SketcherHelper::getInstance()->createCircleSurface(bt->getRadious(),texture,lineColor));
	}else {
		bt->setSurface(SketcherHelper::getInstance()->createCircleSurface(bt->getRadious(),color,lineColor));
	}
	return bt;
}